#查找出以'A'或 'a'开头，并以'c'结尾的所有元素，并添加到一个新列表中，最后循环打印这个列表，移除每个元素的空格
new_li=[]
li=['TaiBai ','alexC','AbC ','egon',' riTiAn','WuSir',' aqc']
for i in li:
    i=i.strip()
    # if (i.startswith('A') or i.startswith('a')) and i.endswith('c'):太麻烦
    if i.upper().startswith('A') and i.endswith('c'):
    #if i[0] in ['A','a'] and i[-1]=='c':
        new_li.append(i)
for i in new_li:
    print(i)
#开发敏感词汇过滤程序，提示用户输入评论内容，如果用户输入的内容包含特殊的字符
#敏感词汇列表 li=["苍老师","东京热","武藤兰","波多野结衣"]
#则将用户输入内容中的敏感词汇换成等长度的*(苍老师就换成***)，并添加到一个列表中；如果用户输入内容没有敏感词汇，直接添加到上述列表中
li=["苍老师","东京热","武藤兰","波多野结衣"]
comment_list=[]
comment=input('请输入.....')
for i in li:
    if i in comment:
        comment=comment.replace(i,'*'*len(i))
        #c=comment_list.append(comment)只添加一次
comment_list.append(comment)
print(comment_list)

li=[1,2,3,4,[5,6,7,8],9,10]
def f(li):

    for i in li:
        try:
            for j in i:
                # print(i)
                f(i)
                break
        except:
           print(i)
f(li)

for i in li:
    if type(i)==list:
        for j in i:
            print(j)
    else:
        print(i)
#将列表中的所有元素组合成字符串
a=['Python','is','awesome']
print(''.join(a))

#查找列表中频率最高的值
a=[1,2,3,1,2,3,2,2,4,5,1]
print(max(set(a),key=a.count))
for i in set(a):
    print(a.count(i))
from collections import Counter
a=[1,2,3,1,2,3,2,2,4,5,1]
cnt=Counter(a)
print(cnt.most_common(3))

#反转字符串
a='123456789'
print(''.join(list(reversed(a))))
print(a[::-1])
num=123456789
print(int(str(num)[::-1]))

#转置二维数组
original=[['a','b'],['c','d'],['e','f']]#变成[a,c,e][b,d,f]
transposed=zip(*original)
print(list(transposed),type(transposed))
original=[['a','b'],['c','d'],['e','f']]#变成[a,c,e][b,d,f]
transposed=zip(*original)
for i in transposed:
    print(i)
for i in zip(['a','b'],['c','d'],['e','f']):
    print(i)

b=6
print(4<b<7)
print(1==b<20)

data=[1,'hello',2,3]
print(','.join(map(str,data)))

